package com.shtel.paas.monitorcenter.config.management.whiteListConfig.web;


import java.util.List;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.github.pagehelper.PageInfo;

import com.shtel.paas.monitorcenter.config.management.alarm.config.service.IWarningConfigService;
import com.shtel.paas.monitorcenter.config.management.whiteListConfig.entity.WhiteListHostIdDto;
import com.shtel.paas.monitorcenter.config.management.whiteListConfig.entity.WhiteListResponseDto;
import com.shtel.paas.monitorcenter.config.management.whiteListConfig.entity.WhiteListRulesDto;
import com.shtel.paas.monitorcenter.config.management.whiteListConfig.service.IWhiteListService;
import com.shtel.paas.sdk.core.RefreshableRestController;
import com.shtel.paas.sdk.core.mybatis.EnablePaasMybatis;

import oracle.net.aso.s;

@EnablePaasMybatis
@MapperScan("com.shtel.paas.monitorcenter.config.management.whiteListConfig.mapper")
// mybatis存储库类的包路径
@RefreshableRestController
public class WhiteListController  {

	@Autowired
	IWhiteListService service;

	
	@GetMapping("/getWhiteListConfig")
	public PageInfo<WhiteListResponseDto> getWhiteListConfig(@RequestParam("hostId") String hostId,
			@RequestParam("rulesId") String rulesId,
			@RequestParam("page") Integer page,
			@RequestParam("pageSize") Integer pageSize){
		if(hostId.equals("")) hostId = null;
		if(rulesId.equals("")) rulesId = null;
		return service.selectAll(hostId,rulesId,page,pageSize);
		
	}
	
	@GetMapping("/getWhiteListHostId")
	public List<WhiteListHostIdDto> getWhiteListHostId(){
		
		return service.selectHostId();
	}
	
	@GetMapping("/getWhiteListRules")
	public List<WhiteListRulesDto> getWhiteListRules(){
		
		return service.selectRules();
	}
	
	@GetMapping("/insertWhiteList")
	public int insertWhiteList(@RequestParam("host") String host,@RequestParam("rules") String rules){
		
		return service.insertWhiteList(host, rules);
	}
	
	/**
	 * 白名单配置页面删除配置controller
	 * @param: 
	 * @author: zhangyy
	 * @Date:   2018.05.16
	 * @return: boolean 
	 */
	@GetMapping("/delectWhiteList")
	public boolean delectWhiteList(@RequestParam("id") String id){
		return service.delectWhiteList(id);
	}
}

